package any.functor.impl.func;

import any.ImmutableAny;
import any.functor.interfaces.Function;
import any.util.Direction;

public abstract class BaseAnyIteratingFunction<TO, DS, AF, T extends BaseAnyIteratingFunction<TO, DS, AF, T>> 
	extends BaseAnyFunction<TO, DS, T> {

	protected Function<ImmutableAny, ?> asFunc;
	
	public BaseAnyIteratingFunction() {
	}

	public BaseAnyIteratingFunction(Class<TO> type) {
		super(type);
	}

	@Override
	public String toString() {
		String str = toStringPrefix();

		if (predicate != null) {
			str += ", where " + predicate;
		}

		if (asFunc != null) {
			str += ", each element ( " + asFunc + " )";
		}		
		
		if (direction == Direction.BACKWARD) {
			str += ", in reverse order";
		}		
		
		return str;
	}

	protected abstract String toStringPrefix();

}
